/**
	@file										Singleton.h
	@author									novo\n\n
	\b E-Mail \n						novopl@gmail.com
	\b Website \n						http://novo.risp.pl
	@date										02.08.2005
	\b Last \b Modyfied \n	02.08.2005


*/
#ifndef __SINGLETON_H__
#define __SINGLETON_H__




template <class T>
class ISingleton{
	static T* m_pSingleton ;
public:
	ISingleton()
	{
#pragma warning(push)
#pragma warning(disable: 4311)
#pragma warning(disable: 4312)
		int offset = (int)(T*)1 - (int)(ISingleton<T>*)(T*)1 ;
		m_pSingleton = (T*)((int)this + offset) ;
#pragma warning(pop)
	}
	~ISingleton()
	{	
		m_pSingleton = 0 ; 
	}
	static T & getSingleton()
	{ 
		return (*m_pSingleton) ;
	}
	static T * getSingletonPtr()
	{
		return m_pSingleton ;
	}
};
template <class T> T* ISingleton <T>::m_pSingleton = 0;

// end of nstd namespace.

#endif//__SINGLETON_H__